<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // generator函数 -- 中间能停
        function *show(){
            console.log('1');
            yield;
            console.log('2');
        }

        let getObj = show();
        getObj.next();
        getObj.next();

        console.log('-----分割线-----');

        // yield可以传参
        function *show1(a){
            console.log(a);
            console.log(1);
            let b = yield;
            console.log(b);
            console.log(2);
        }

        let gen1 = show1('a');
        gen1.next();
        gen1.next('b');

        // yield可以返回

        function *show2(a){
            console.log(a);
            console.log(1);
            let b = yield 12;
            console.log(b);
            console.log(2);
        }

        let gen2 = show2('a');
        let res1 = gen2.next();
        console.log(res1);
        let res2 = gen2.next('b');
        console.log(res2);

        var initGeneratorFn = (function(){
            
        });

        initGeneratorFn();
    </script>
</body>
</html>